package com.example.app2024.fragment;

import android.os.Bundle;
import android.text.Layout;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.example.app2024.R;

public class FragmentDymicActivity extends AppCompatActivity
{
      Button btn;
      FragmentManager manager;
      LinearLayout linearLayout;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
            super.onCreate(savedInstanceState);
            EdgeToEdge.enable(this);
            setContentView(R.layout.activity_fragment_dymic);
            ViewCompat.setOnApplyWindowInsetsListener(
                    findViewById(R.id.main), (v, insets) -> {
                          Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
                          v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
                          return insets;
                    });

            manager = getSupportFragmentManager();
            linearLayout = findViewById(R.id.left31);

            btn = findViewById(R.id.btnShowall);
            btn.setOnClickListener(new View.OnClickListener()
            {
                  @Override
                  public void onClick(View v)
                  {
                        linearLayout.setLayoutParams(new LinearLayout.LayoutParams( getWindowManager().getDefaultDisplay().getWidth()/3,
                                getWindowManager().getDefaultDisplay().getHeight()));

                        FragmentTransaction transaction = manager.beginTransaction();
                        transaction.replace(R.id.main , new Fragment_dymic());
                        transaction.addToBackStack(null);  //可以监听到返回退出键
                        transaction.commit();
                  }
            });
      }
}